<template>
  <div class="myUpdatePassword">
    <!-- 头部导航 -->
    <myheader title="修改密码" rightBtn="确定修改" @updataInfo="updatePwd"></myheader>

    <my-input>
      <template v-slot:myinput_title>
        <i
          class="van-badge__wrapper van-icon van-icon-undefined el-icon-unlock"
          style="color: rgb(57, 169, 237); font-size: 25px;"
        ></i>
        原密码：
      </template>
      <template v-slot:myinput_input>
        <el-input placeholder="请输入旧密码" show-password v-model="oldpassword"></el-input>
      </template>
    </my-input>

    <my-input>
      <template v-slot:myinput_title>
        <svg
          t="1630720084212"
          class="icon"
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="13597"
          width="200"
          height="200"
        >
          <path
            d="M811.739429 435.2c45.153524 0 81.773714 34.377143 81.773714 76.8v358.4c0 42.422857-36.62019 76.8-81.773714 76.8H212.260571c-45.153524 0-81.773714-34.377143-81.773714-76.8V512c0-42.422857 36.62019-76.8 81.773714-76.8h599.478858m0-76.8H212.260571C121.904762 358.4 48.761905 427.154286 48.761905 512v358.4C48.761905 955.245714 121.953524 1024 212.260571 1024h599.478858C902.095238 1024 975.238095 955.245714 975.238095 870.4V512c0-84.845714-73.191619-153.6-163.498666-153.6zM512 76.8c105.325714 0 190.756571 80.213333 190.756571 179.2v102.4H321.243429v-102.4c0-98.986667 85.430857-179.2 190.756571-179.2M512 0C361.520762 0 239.518476 114.590476 239.518476 256v179.2h544.963048V256C784.481524 114.590476 662.479238 0 512 0h-0.097524 0.097524z m0 806.424381c-22.576762 0-40.862476-17.212952-40.862476-38.424381V614.4c-0.828952-21.211429 16.774095-39.009524 39.350857-39.789714 22.528-0.78019 41.496381 15.798857 42.325333 36.961524V768c0 21.211429-18.285714 38.424381-40.862476 38.424381H512z"
            fill="#bfbfbf"
            p-id="13598"
          />
        </svg>
        新密码：
      </template>
      <template v-slot:myinput_input>
        <el-input placeholder="请输入新密码" show-password v-model="newpassword"></el-input>
      </template>
    </my-input>

    <my-input>
      <template v-slot:myinput_title>
        <svg
          t="1630720084212"
          class="icon"
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="13597"
          width="200"
          height="200"
        >
          <path
            d="M811.739429 435.2c45.153524 0 81.773714 34.377143 81.773714 76.8v358.4c0 42.422857-36.62019 76.8-81.773714 76.8H212.260571c-45.153524 0-81.773714-34.377143-81.773714-76.8V512c0-42.422857 36.62019-76.8 81.773714-76.8h599.478858m0-76.8H212.260571C121.904762 358.4 48.761905 427.154286 48.761905 512v358.4C48.761905 955.245714 121.953524 1024 212.260571 1024h599.478858C902.095238 1024 975.238095 955.245714 975.238095 870.4V512c0-84.845714-73.191619-153.6-163.498666-153.6zM512 76.8c105.325714 0 190.756571 80.213333 190.756571 179.2v102.4H321.243429v-102.4c0-98.986667 85.430857-179.2 190.756571-179.2M512 0C361.520762 0 239.518476 114.590476 239.518476 256v179.2h544.963048V256C784.481524 114.590476 662.479238 0 512 0h-0.097524 0.097524z m0 806.424381c-22.576762 0-40.862476-17.212952-40.862476-38.424381V614.4c-0.828952-21.211429 16.774095-39.009524 39.350857-39.789714 22.528-0.78019 41.496381 15.798857 42.325333 36.961524V768c0 21.211429-18.285714 38.424381-40.862476 38.424381H512z"
            fill="#bfbfbf"
            p-id="13598"
          />
        </svg>
        新密码：
      </template>
      <template v-slot:myinput_input>
        <el-input placeholder="请再次输入密码" show-password v-model="twopassword"></el-input>
      </template>
    </my-input>
  </div>
</template>

<script>
import { Notify } from 'vant'
import myInput from '../../comon/myInput.vue' //我的信息插槽
import myheader from '../../comon/myheader.vue' //头文件
import { isPassword } from '../../utils/tools'
export default {
  components: {
    myheader,
    myInput,
  },
  data() {
    return {
      oldpassword: '',
      newpassword: '',
      twopassword: '',
    }
  },
  methods: {
    updatePwd() {
      // 密码格式验证
      if (isPassword(this.newpassword)) {
        console.log(1)
        if (this.newpassword != this.twopassword) {
          Notify({ type: 'warning', message: '两次密码不一致' })
          return
        }
        this.$axios
          .post('/sys/user/updatePass', {
            jwt: this.$store.getters.getToken,
            currentPass: this.oldpassword,
            password: this.newpassword,
          })
          .then((r) => {
            if (r.data.code == 200) {
              Notify({ type: 'success', message: r.data.msg })
              this.$router.go(-1)
            }
          })
      }
    },
  },
}
</script>

<style scoped>
.myUpdatePassword {
  margin-top: 46px;
}
.myinput_title {
  width: 27% !important;
  font-size: 0.42667rem;
  margin: auto;
  text-align: justify;
  display: flex !important;
  justify-content: space-around !important;
  align-items: center !important;
}
</style>
